/**
 * @param {number[]} nums
 * @return {number[]}
 */
var smallerNumbersThanCurrent = function(nums) {
    var arr = []
    var length = nums.length
    for (var i = 0; i < length; i++) {
        var count = 0
        for (var j = length - 1; j >= 0; j--) {
            if (nums[i] > nums[j]) {
                count++
            }
        }
        arr[i] = count
    }
    return arr
};

console.log(smallerNumbersThanCurrent([6,5,4,8]));